package thread;

public class OrderReSort {
    int x = 0, y = 0;
    public void write() {
        for (int j = 2; j <= 400; j += 2) {
            for (int i = 1; i <= 200; i++) {
                x = i;
                y = j;
            }
        }
    }
    
    public void read() {
        int r1 = y;
        int r2 = x;
        while (true) {
            r1 = y;
            r2 = x;
            if (r1 != 2 * r2)
                break;
        }
        System.out.println(r1);
        System.out.println(r2);
    }

    public static void main(String[] args) {
        OrderReSort orderReSort = new OrderReSort();
        new Thread(new Write(orderReSort)).start();
        new Thread(new Read(orderReSort)).start();
    }

}

class Write implements Runnable {
    private OrderReSort orderReSort;
    public Write(OrderReSort orderReSort) {
        this.orderReSort = orderReSort;
    }
    @Override
    public void run() {
        orderReSort.write();
    }
}

class Read implements Runnable {
    private OrderReSort orderReSort;
    public Read(OrderReSort orderReSort) {
        this.orderReSort = orderReSort;
    }
    @Override
    public void run() {
        orderReSort.read();
    }
}
